<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="include :: header"></head>
<body>
<form class="layui-form" style="padding: 15px;">
    <div class="layui-inline">
        <label class="layui-form-label">任务标题</label>
        <div class="layui-input-inline">
            <input type="text" id="workTitle" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">项目名称</label>
        <div class="layui-input-inline">
            <input type="text" id="projectName" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">周次过滤</label>
        <div class="layui-input-inline">
            <select id="weeklydata">
                <option value="">全部</option>
                <option value="1">本周</option>
                <option value="2">上周</option>
            </select>
        </div>
    </div>
    <button class="layui-btn layui-btn-sm"><i class="layui-icon"></i>
    </button>
</form>
<table id="epointprojectList" class="layui-hide" lay-filter="epointweeklywork"></table>

<script type="text/html" id="toolbarTable">
    <button class="layui-btn layui-btn-sm" shiro:hasPermission="system:epointweeklywork:add"
            onclick="openWindow('添加工作信息','/venus/project/epointweeklywork/add')"><i
            class="layui-icon"></i>添加
    </button>
</script>

<script type="text/html" id="toolbar">
    <a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="view">查看</a>
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<div th:include="include :: footer"></div>

<script>
    var sysUrl = '/venus/project/epointweeklywork';
    layui.use(['table'], function () {
        var table = layui.table;
        table.render({
            id: 'epointprojectList',
            elem: '#epointprojectList',
            method: 'post',
            height: 'full-100',
            toolbar: '#toolbarTable',
            totalRow: true,
            defaultToolbar: ['print', 'exports'],
            cellMinWidth: 130,
            url: sysUrl + '/list',
            cols: [
                [
                    {field: 'num', width: 50, title: '序号', type: 'numbers'},
                    {field: 'workTitle', width: 420, title: '任务标题'},
                    {field: 'projectName', width: 250, title: '项目名称'},
                    {
                        field: 'workType', width: 100, title: '工作类型', totalRowText: '工时合计', templet: function (d) {
                            if (d.workType == 'P') {
                                return "<sapn style='color: green'>项目需求</sapn>";
                            } else if (d.workType == 'B') {
                                return "<sapn style='color: blue'>知识库</sapn>";
                            } else if (d.workType == 'G') {
                                return "<sapn style='color: red'>评审设计</sapn>";
                            }
                        }
                    },
                    {field: 'totalHour', width: 110, totalRow: true, title: '计划工时(h)'},
                    {field: 'weeklyHour', width: 110, totalRow: true, title: '本周工时(h)'},
                    {
                        field: 'weekRange', width: 210, title: '所属范围', templet: function (d) {
                            return "从" + getDateStr(d.weekStartDate) + '到' + getDateStr(d.weekEndDate);
                        }
                    },
                    {field: 'workContent', title: '工作内容'},
                    {fixed: 'right', title: '操作', toolbar: "#toolbar"}
                ]
            ]
            , page: true
        });

        //监听行工具事件
        table.on('tool(epointweeklywork)', function (obj) {
            delAndEdit(sysUrl, obj, 'work');
        });
        //搜索
        $('.layui-form .layui-btn').on('click', function () {
            var thisWeek = null;
            var val = $("#weeklydata").val();
            if (val != null) {
                if ("1" == val) {
                    thisWeek = getCurMonday(new Date());
                }
                else if ("2" == val) {
                    thisWeek = getLastMonday(new Date());
                }
            }
            table.reload('epointprojectList', {
                where: {
                    projectName: $("#projectName").val(),
                    workTitle: $("#workTitle").val(),
                    weekStartDate: thisWeek
                }
            });
            return false;
        });
    });
</script>
</body>
</html>